
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <button onclick="add()">计算两数运算结果</button>
</body>
<script>
    function add() {
        let n1 = parseFloat(prompt("请输入第一个数"))
        let n2 = parseFloat(prompt("请输入第二个数"))
        let sign = prompt("请输入运算符号")
    document.write(n1 + sign + n2 + "=")
        if (sign === '*') {
            let count = n1 * n2
            document.write(count)
        } else if (sign === "/") {
            let count = n1 / n2
            document.write(count)
        } else if (sign === "+") {
            let count = n1 + n2
            document.write(count)
        } else if (sign === "-") {
            let count = n1 - n2
            document.write(count)
        } else {
            lert("表达式错误！！！")
        }
    }

</script>
</html>